package com.snacksmall.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.snacksmall.dto.AddressDto;
import com.snacksmall.model.Address;
import com.snacksmall.service.IAddressService;

@Controller
@ResponseBody
@RequestMapping("/address")
public class AddressController {
	@Resource
	private IAddressService addressService;
	@RequestMapping("/queryAddressAll.do")
	public Map queryAddressAll(AddressDto addressDto) {
		List<Address> list = addressService.queryAddressAll(addressDto);
	    int num = addressService.countAddressAll(addressDto);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("code",0);
		map.put("msg","");
	    map.put("count",num);
	    map.put("data",list);
		return map;
		
	}
	@RequestMapping("/addAddress.do")
	public int addAddress(Address address) {
		
		return addressService.addAddress(address);
		
	}
	@RequestMapping("/editAddress.do")
	public int editAddress(Address address) {
		return addressService.editAddress(address);
		
	}
	@RequestMapping("/delAddress.do")
	public int delAddress(int addressId) {
		return addressService.delAddress(addressId);
		
	}
	
}
